package com.tom.service.impl;

import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.tom.util.HttpRequest;
import com.tom.util.JDBCUtil;

public class HttpClientServiceImpl {
	
	/***
	 * 鲁金所获取url地址
	 */
	public static void work(){
		String url = "https://www.lujinsuop2p.com/web/hm/bor/l.htm";
		ArrayList<String> list = new ArrayList<String>();
		for(int i = 1 ; i <= 151 ; i++){
			String param = "pageNum=";
			param += i;
			String result = HttpRequest.sentPost(url, param);
			System.out.println(result);
			JSONObject jsonResult = JSON.parseObject(result);
			JSONArray jsonList = (JSONArray) jsonResult.get("results");
			for(int j = 0 ; j < jsonList.size() ; j++){
				JSONObject item = (JSONObject) jsonList.get(j);
				//System.out.println(item.get("borIdEncrypt").toString());
				String itemUrl = "https://www.lujinsuop2p.com/web/hm/bor/v.htm?id=" + item.get("borIdEncrypt").toString();
				System.out.println(itemUrl);
				list.add(itemUrl);
				//System.out.println(jsonList.get(j).toString());
			}
		}
		//添加数据库操作
		/*try {
			JDBCUtil.insertUrls(list,"qss_lujinsuo_url");
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
	}
	/***
	 * 获取中融宝的业务数据url
	 */
	public static void work2(){
		// 顺序依次是小微链，科技创新，绿色三农，新零售，产能升级，社区金服
		String[] urlArry = {
				"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%22--pagenum--%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22newBorrowConditions%22%2C%22borrowTypes%22%3A%2201%2C02%2C03%2C04%2C17%2C18%2C26%2C33%2C34%22%7D%7D%7D&_=1522287029383",
				"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%22--pagenum--%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22newBorrowConditions%22%2C%22borrowTypes%22%3A%2241%22%7D%7D%7D&_=1522305122553",
				"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%22--pagenum--%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22newBorrowConditions%22%2C%22borrowTypes%22%3A%2213%2C14%2C15%2C16%22%7D%7D%7D&_=1522306437619",
				"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%22--pagenum--%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22newBorrowConditions%22%2C%22borrowTypes%22%3A%2240%22%7D%7D%7D&_=1522306521145",
				"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%22--pagenum--%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22newBorrowConditions%22%2C%22borrowTypes%22%3A%2239%22%7D%7D%7D&_=1522306588455",
				"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%22--pagenum--%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22newBorrowConditions%22%2C%22borrowTypes%22%3A%2205%2C06%2C07%2C08%2C09%2C10%2C11%2C12%2C25%2C32%2C37%22%7D%7D%7D&_=1522306651490" };
		int[] pageArry = { 193, 13, 27, 13, 10, 16 };

		for (int a = 0; a < urlArry.length; a++) {
			System.out.println(urlArry[a]);
			ArrayList<String> list = new ArrayList<String>();
			String url = urlArry[a];
			for (int i = 1; i <= pageArry[a]; i++) {
				String resultUrl = url.replace("--pagenum--", i + "");
				System.out.println(i + "--" + resultUrl);
				// param += i;
				String result = HttpRequest.sendGet(resultUrl);
				// 去掉非json字符串
				result = result.replace(
						"jQuery1113023197166858206564_1522287029380", "");
				result = result.replace("(", "");
				result = result.replace(")", "");
				// System.out.println("---"+result);
				JSONObject jsonResult = JSON.parseObject(result);
				JSONObject body = jsonResult.getJSONObject("body");
				JSONObject pageInfo = body.getJSONObject("pageInfo");
				JSONArray pageList = pageInfo.getJSONArray("pageData");
				System.out.println(pageList.size());
				for (int j = 0; j < pageList.size(); j++) {
					JSONObject item = (JSONObject) pageList.get(j);
					//只存储id
					//String itemUrl = "https://www.zrbao.com/borrowSkip/"
					//		+ item.get("bid").toString() + ".shtml";
					String itemUrl = item.get("bid").toString();
					list.add(itemUrl);
					System.out.println(itemUrl);
				}
			}
			//添加数据库操作
			try {
				JDBCUtil.insertUrls(list, "qss_zhongrongbao_url");
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	//处理中融宝的业务数据
	public static void work3(){
		try {
			ArrayList<HashMap<String, String>> list = JDBCUtil.getJsonData();
			ArrayList<String> result = new ArrayList<String>();
			for(int i = 0 ; i < list.size() ; i ++){
				HashMap<String, String> map = list.get(i);
				String id = map.get("item_id");
				System.out.println("-----"+i+"------");
				System.err.println(id);
				String json1 = map.get("json1");
				JSONObject json = JSONObject.parseObject(json1);
				JSONObject data = json.getJSONObject("data");
				String borrowName = data.getString("borrowName");
				String borrowTypeName = data.getString("borrowTypeName");
				String investAmt = data.getString("investAmt");
				String deadline = data.getString("deadline");
				String annualRate = data.getString("annualRate");
				String borrowStatus = data.getString("borrowStatus");
				String borrowAmtWan = data.getString("borrowAmtWan")+"万元";
				String pct = data.getString("pct");
				String repaymentWayName = data.getString("repaymentWayName");
				//System.out.println(borrowName);
				String json2 = map.get("json2");
				String repaymentSource = "";
				String borrowUserName = "";
				String borrowerNature = "";
				String borrowLocation = "";
				String cate = "";
				String moneyPurposes = "";
				String agencyMan = "";
				String agencyCapital = "";
				String agencyOffice = "";
				String agencyCreattime = "";
				try{
					repaymentSource = json2.split("repaymentSource")[1].split("\"")[2];
					borrowUserName = json2.split("borrowUserName")[1].split("\"")[2];
					borrowerNature = json2.split("borrowerNature")[1].split("\"")[2];
					borrowLocation = json2.split("borrowLocation")[1].split("\"")[2];
					cate = json2.split("cate")[1].split("\"")[2];
					moneyPurposes = json2.split("moneyPurposes")[1].split("\"")[2];
					agencyMan = json2.split("agencyMan")[1].split("\"")[2];
					agencyCapital = json2.split("agencyCapital")[1].split("\"")[2];
					agencyOffice = json2.split("agencyOffice")[1].split("\"")[2];
					agencyCreattime = json2.split("agencyCreattime")[1].split("\"")[2];
				}catch(Exception e){
					
				}
				String json3 = map.get("json3");
				String json4 = map.get("json4");
				String json5 = map.get("json5");
				String publishtimedet = "";
				String examtinetimedet = "";
				try{
					publishtimedet = json5.split("publishtimedet")[1].split("\"")[2];
					examtinetimedet = json5.split("examtinetimedet")[1].split("\"")[2];
				}catch(Exception e){
					
				}
//				String publishtimedet = json5.split("publishtimedet")[1].split("\"")[2];
//				String examtinetimedet = json5.split("examtinetimedet")[1].split("\"")[2];
				System.out.println(examtinetimedet);
				Date now = new Date(); 
				SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
				String time = dateFormat.format(now); 
				String sql = "insert into qss_zhongrongbao_bussiness_data(project_name,bussiness_type,total_money,annual_rate,project_status,loan_money,deadline,progress,repayment_way,repayment_source,project_info,project_start_time,project_end_time,guarantee_way,rule_repayment_date,actual_repayment_date,repayment_status,repayment_type,repayment_money,is_expire,penalty,loan_main,loan_person_type,project_locate,loan_person_bussiness,loan_use,legal_person,register_capital,work_place,establish_time,finance_data,law_status,credit_record,url,insert_time) values"
						+ "('"+borrowName+"','"+borrowTypeName+"','"+investAmt+"','"+annualRate+"','"+borrowStatus+"','"+borrowAmtWan+"','"+deadline+"','"+pct+"','"+repaymentWayName+"','"+repaymentSource+"','project_info','"+publishtimedet+"','"+examtinetimedet+"','guarantee_way','rule_repayment_date','actual_repayment_date','repayment_status','repayment_type','repayment_money','is_expire','penalty','"+borrowUserName+"','"+borrowerNature+"','"+borrowLocation+"','"+cate+"','"+moneyPurposes+"','"+agencyMan+"','"+agencyCapital+"','"+agencyOffice+"','"+agencyCreattime+"','finance_data','通过全国法院被执行人信息查询系统、全国法院失信被执行人名单信息公布与查询平台及互联网搜索，未发现借款人及企业涉诉信息。','通过人民银行征信报告显示，借款人及借款企业无不良信用记录，资信良好。借款人在平台无逾期，逾期金额、逾期次数均为零。','"+id+"','"+time+"')";
				result.add(sql);
				System.err.println(sql);
			}
			//添加数据库操作
			JDBCUtil.insertData(result);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e){

		}
	}
	/***
	 * 获取中融宝的业务的json数据
	 */
	public static void main(String[] args){
		//中融宝业务数据的四个post请求
		String[] urlArry = {
				"https://www.zrbao.com/borrow/getBorrowDtlMes.shtml",
				"https://www.zrbao.com/borrow/getBorrowDetailsMes.shtml",
				"https://www.zrbao.com/borrow/queryInvestList.shtml",
				"https://www.zrbao.com/borrow/borrowRepayment.shtml",
				"https://www.zrbao.com/dataFun/dataQuery"};
		ArrayList<String> list = new ArrayList<String>();
		ArrayList<String> result1 = new ArrayList<String>();
		ArrayList<String> result2 = new ArrayList<String>();
		ArrayList<String> result3 = new ArrayList<String>();
		ArrayList<String> result4 = new ArrayList<String>();
		ArrayList<String> result5 = new ArrayList<String>();
		String cookies = "username=15092200806; Hm_lvt_b4e112a89209d15dd495141817984363=1522120724,1522226671,1522286995,1522675284; ZRBAO_TOKEN=6a6733a886314663a76e6811bd18e4b5; ZRBAO_IMG_CODE_KEY=a808700653f44f4691b233de62c808a3; Hm_lpvt_b4e112a89209d15dd495141817984363=1522675462; JSESSIONID=DCD8D6D2F49E9460953546905724C073";
		try {
			list = JDBCUtil.getUrls("qss_zhongrongbao_url");
			for(int i = 0 ; i < list.size() ; i ++){
				//System.err.println(list.get(i));
				//只获取id
				//String id = list.get(i).split("borrowSkip/")[1].split(".shtml")[0];
				System.out.println("----"+i+"----");
				String id = list.get(i);
				String json1 = HttpRequest.postByCookies(urlArry[0], "jsonDataSet={\"bid\":"+id+"}", cookies);
				//System.err.println("josn1---"+json1);
				result1.add(json1);
				String json2 = HttpRequest.postByCookies(urlArry[1], "jsonDataSet={\"bid\":"+id+"}", cookies);
				//System.err.println("josn2---"+json2);
				result2.add(json2);
				String json3 = HttpRequest.postByCookies(urlArry[2], "jsonDataSet={\"bid\":"+id+"}", cookies);
				//System.err.println("josn3---"+json3);
				result3.add(json3);
				String json4 = HttpRequest.postByCookies(urlArry[3], "jsonDataSet={\"bid\":"+id+"}", cookies);
				//System.err.println("josn4---"+json4);
				result4.add(json4);
				String json5 = HttpRequest.postByCookies(urlArry[4], "dataMsg={\"Head\":{\"channelType\":\"01\",\"interfaceVersion\":\"1.0\",\"funCode\":\"dataQuery\",\"sid\":\"7476CCDC1D5E25529C0063177FE72AC5\"},\"Body\":{\"pageInfo\":{\"pageNum\":\"1\"},\"param\":{\"queryId\":\"projectProcess\",\"bid\":"+id+"}}}", cookies);
				System.err.println("josn5---"+json5);
				result5.add(json5);
				System.err.println(id);
			}
			//添加数据库操作
			JDBCUtil.insertJson(list,result1, result2, result3, result4,result5);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
		/**
		 * 
		 * @author hanpengda
		 * @date 2018年4月27日
		 * @TODO 中融宝运营json数据
		 * 
		 */
		public static void work4(){
			String [] urlArray = {
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%221%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22leijitouzi%22%7D%7D%7D&_=1524808220649",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22param%22%3A%7B%22queryId%22%3A%22yuetouzi%22%2C%22year%22%3A%222018%22%7D%7D%7D&_=1524808220647",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22param%22%3A%7B%22queryId%22%3A%227dayData%22%7D%7D%7D&_=1524808220648",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22param%22%3A%7B%22queryId%22%3A%22nianlingduan%22%7D%7D%7D&_=1524808220650",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22param%22%3A%7B%22queryId%22%3A%22yonghuzhucebili%22%7D%7D%7D&_=1524808220653",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22param%22%3A%7B%22queryId%22%3A%22dakehuzhanbi%22%7D%7D%7D&_=1524808220654",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B\"Head\"%3A%7B\"channelType\"%3A\"01\"%2C\"interfaceVersion\"%3A\"2.0\"%2C\"funCode\"%3A\"dataQuery\"%2C\"sid\"%3A\"32B1194CE9CDF8ACA2F6987966CD6B88\"%7D%2C\"Body\"%3A%7B\"param\"%3A%7B\"queryId\"%3A\"borroweramount\"%7D%7D%7D&_=1524808220656",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22param%22%3A%7B%22queryId%22%3A%22todayhuoyueyonghu%22%7D%7D%7D&_=1524808220658",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%221%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22biaodiqingkuang%22%7D%7D%7D&_=1524808220659",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22param%22%3A%7B%22queryId%22%3A%22rongziqixian%22%7D%7D%7D&_=1524808220661",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22param%22%3A%7B%22queryId%22%3A%22dishitouziTop10%22%7D%7D%7D&_=1524808220664",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22param%22%3A%7B%22queryId%22%3A%22zijinqianyi1L%22%7D%7D%7D&_=1524808220666",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22param%22%3A%7B%22queryId%22%3A%22touzi30day%22%7D%7D%7D&_=1524808220668",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%221%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22yqCount%22%7D%7D%7D&_=1524808220670",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%227476CCDC1D5E25529C0063177FE72AC5%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%221%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22lilvzoushitouzi%22%2C%22year%22%3A%222018%22%7D%7D%7D&_=1524808220672",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%221%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22amountyuqi%22%7D%7D%7D&_=1524808220674",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%221%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22projectyuqi%22%7D%7D%7D&_=1524808220675",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%221%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22yuqixiangqing%22%7D%7D%7D&_=1524808220677",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%221%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22zuikuaimanbiao%22%7D%7D%7D&_=1524808220678",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%221%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22zuimanmanbiao%22%7D%7D%7D&_=1524808220679",
					"https://pay.zrbao.com/datafun?jsonpcallback=&dataMsg=%7B%22Head%22%3A%7B%22channelType%22%3A%2201%22%2C%22interfaceVersion%22%3A%222.0%22%2C%22funCode%22%3A%22dataQuery%22%2C%22sid%22%3A%2232B1194CE9CDF8ACA2F6987966CD6B88%22%7D%2C%22Body%22%3A%7B%22pageInfo%22%3A%7B%22pageNum%22%3A%221%22%7D%2C%22param%22%3A%7B%22queryId%22%3A%22rongzihuankuanjh%22%7D%7D%7D&_=1524808220680"
			};
			ArrayList<String> list = new ArrayList<String>();
			for(int i = 0; i < urlArray.length; i++){
				System.out.println("----------start:"+i+"-------");
				System.out.println(urlArray[i]);
				String result = HttpRequest.sendZrbYyGet(urlArray[i]);
				JSONObject jsonResult = JSON.parseObject(result);
				JSONObject body = jsonResult.getJSONObject("body");
				JSONArray data = body.getJSONArray("data");
				System.out.println(data);
				list.add(data.toString());
				System.out.println("----------end:"+i+"---------");
			}
			//添加数据库操作
			/*try {
				JDBCUtil.insertYyJson(list, "qss_zhongrongbao_yysj_json");
				System.out.println("----------加入数据库成功--------");
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}*/
		}
		
		/**
		 * 
		 * @author hanpengda
		 * @date 2018年4月27日
		 * @TODO 中融宝运营数据处理
		 */
		public static void work5(){
			//累计投资
			String [] columns = {"investornum","baddebt","avgfulltime","manavginvestamt","overprincipal",
					"maxtenborrow","totalinvestamt","borrowernum","yesterdayinvestamt","joinusercount","maxoneborrow",
					"hasrepayprincipal","cutofftime","lateamtprop","todayinvestamt","suminterest",
					"manavgborrowamt","compensatoryamt","lateamt","borrowbalance","avginvestamt","expectincome",
					"avgborrowamt",
			};
			
			String param = "leijitouzi";
			String tableName = "qss_zrb_operation_info";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work6(){
			//月出借额
			String [] columns = {"cutofftime","investamt","investyearmonth"};
			
			String param = "yuetouzi";
			String tableName = "qss_zrb_operation_ycje";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work7(){
			//七日数据播报
			String [] columns = {"dayinvestamt","dayprincipal","dayinterest"};
			
			String param = "7dayData";
			String tableName = "qss_zrb_operation_7dayData";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		public static void work8(){
			//年龄段比例
			String [] columns = {"agename","cutofftime","ageprop"};
			String param = "nianlingduan";
			String tableName = "qss_zrb_operation_nianlingduan";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		public static void work9(){
			//注册用户出借比例
			String [] columns = {"cutofftime","investcountname","investcount","regcountname","regcount"};
			String param = "yonghuzhucebili";
			String tableName = "qss_zrb_operation_yonghuzhucebili";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work10(){
			//大客户出借金额占比
			String [] columns = {"invest5wamt","invest10wamt","invest30wamt","invest50wamt","invest100wamt","invest100wsamt"};
			String param = "dakehuzhanbi";
			String tableName = "qss_zrb_operation_dakehuzhanbi";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work11(){
			//借款人待还金额占比
			String [] columns = {"zrbname","zrbvalue"};
			String param = "borroweramount";
			String tableName = "qss_zrb_operation_borroweramount";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work12(){
			//当日活跃用户
			String [] columns = {"webname","web","androidname","android","iosname","ios","cutofftime"};
			String param = "todayhuoyueyonghu";
			String tableName = "qss_zrb_operation_todayhuoyueyonghu";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work13(){
			//标的统计
			String [] columns = {"overduenum","inbid","flowbid","todayrepaymentover","trailerbid","todayrepayment","overbid","repayment","cutofftime"};
			String param = "biaodiqingkuang";
			String tableName = "qss_zrb_operation_biaodiqingkuang";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work14(){
			//借款期限分布
			String [] columns = {"arrayNo4","bidcountNo4","deadline","cutofftime"};
			String param = "rongziqixian";
			String tableName = "qss_zrb_operation_rongziqixian";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work15(){
			//中融宝最近30天出借情况
			String [] columns = {"investamtNo20","cutofftimeNo20","investtimeNo20"};
			String param = "touzi30day";
			String tableName = "qss_zrb_operation_touzi30day";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work16(){
			//逾期统计
			String [] columns = {"yql","dcamt","yq3l","jdhz","yqamt","weiyue","jdyql"};
			String param = "yqCount";
			String tableName = "qss_zrb_operation_yqCount";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work17(){
			//平台年化利率走势和出借关系
			String [] columns = {"monthrate","investamt","ratetime","cutofftime"};
			String param = "lilvzoushitouzi";
			String tableName = "qss_zrb_operation_lilvzoushitouzi";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work18(){
			//金额分级逾期率(%)
			String [] columns = {"zrbname","zrbvalue"};
			String param = "amountyuqi";
			String tableName = "qss_zrb_operation_amountyuqi";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work19(){
			//项目分级逾期率
			String [] columns = {"zrbname","zrbvalue"};
			String param = "projectyuqi";
			String tableName = "qss_zrb_operation_projectyuqi";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work20(){
			//逾期详情
			String [] columns = {"borrowId","note","realRepayDate","receivableFine","repayAmt","repayDate","repayPeriod","repayStatus"};
			String param = "yuqixiangqing";
			String tableName = "qss_zrb_operation_yuqixiangqing";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work21(){
			//最慢满标时间
			String [] columns = {"bidNo34","borrowamtNo34","borrowtypeNo34","cutofftime","deadlineNo34","deadlinetypeNo34","investcountNo34","projectnameNo34","timeconsumeNo34","yearrateNo34"};
			String param = "zuimanmanbiao";
			String tableName = "qss_zrb_operation_zuimanmanbiao";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work22(){
			//最快满标时间
			String [] columns = {"bidNo33","borrowamtNo33","borrowtypeNo33","cutofftime","deadlineNo33","deadlinetypeNo33","investcountNo33","projectnameNo33","timeconsumeNo33","yearrateNo33"};
			String param = "zuikuaimanbiao";
			String tableName = "qss_zrb_operation_zuikuaimanbiao";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
		public static void work23(){
			//还款计划
			String [] columns = {"bidNo36","cutofftime","deadlineNo36","projectnameNo36","realrepaytimeNo36","repayamtNo36","repaytimeNo36","yearrateNo36"};
			String param = "rongzihuankuanjh";
			String tableName = "qss_zrb_operation_rongzihuankuanjh";
			JDBCUtil.zrbInsertData(columns, param,tableName);
		}
		
}
